﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using YGWebMobileApi.Data;
using OneMile.Common;
using OneMile.Entity.Model;
using OneMile.BLL;

namespace YGWebMobileApi.APIs
{
    [MobileAPI(Code = "MC0302", Name = "用户重复下订单")]
    public class UAddNewOrderAgain : IProcessMessage
    {
        private BLLUOrder bll;
        public BLLUOrder BLL
        {
            get
            {
                if (bll == null)
                    bll = BLLFactory.getInstance().CreateUOrderBLL();
                return bll;
            }
        }


        #region IProcessMessage 成员

        public MobileRspMsg ProcessMessage(MobileReqMsg reqMsg)
        {
            try
            {
        
                MobileRspMsg rspMsg = new MobileRspMsg(reqMsg);
                // 获取参数字段（具体请参见文档）
                string OrderId = reqMsg.Body.GetFieldValue("OrderId");
                if (string.IsNullOrEmpty(OrderId))
                {
                    rspMsg.Head.RspCode = MessageCode.Paramter_Empty.Code;
                    rspMsg.Head.RspMsg = MessageCode.Paramter_Empty.Msg;
                    return rspMsg;
                }

                if (BLL.InsertOrderAgain(OrderId))
               {
                  rspMsg.Head.RspCode = MessageCode.Success.Code;
                  rspMsg.Head.RspMsg = MessageCode.Success.Msg;

                  return rspMsg;
                }
                else
                {
                   rspMsg.Head.RspCode = MessageCode.Server_Error.Code;
                   rspMsg.Head.RspMsg = MessageCode.Server_Error.Msg;

                   return rspMsg;
                }    
            }
            catch (Exception e)
            {

                ErrorLogWriter.Write("UGetCommodityListByShopId-" + e);
                throw e;
            }
        #endregion
         } 
    }
}